//
//  AboutViewController.m
//  News
//
//  Created by Han on 15-4-16.
//  Copyright (c) 2015年 IPingLun. All rights reserved.
//

#import "AboutViewController.h"
#import <objc/runtime.h>

@interface AboutViewController () {
    UITableView *mTableView;
    UIRefreshControl *mRefreshControl;
    NSMutableArray *mData;
    
    BOOL cellHeightCacheEnabled;
}

@end

@implementation AboutViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    mData = NSMutableArray.new;
    
    [self drawView];
    cellHeightCacheEnabled = YES;
    
}



- (void)drawView {
    
    self.view.backgroundColor = BG_COLOR;
    
    UIView *navigationBar = UIView.new;
    navigationBar.backgroundColor = NAV_COLOR;
    [self.view addSubview:navigationBar];
    
    UIView *parentView = self.view;
    
    [navigationBar makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(parentView.top).offset(0);
        make.left.equalTo(parentView.left).offset(0);
        make.right.equalTo(parentView.right).offset(0);
        make.height.equalTo(54);
    }];
    
    UILabel *titleLabel = UILabel.new;
    titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
    titleLabel.text = @"关于我们";
    titleLabel.textColor = UIColorFromRGB(0x333333);
    [navigationBar addSubview:titleLabel];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(navigationBar);
        make.top.equalTo(navigationBar.top).offset(20);
        make.bottom.equalTo(navigationBar.bottom).offset(0);
    }];
    
    
    UIButton *backButton = UIButton.new;
    [backButton setImage:[UIImage imageNamed:@"back_nav_icon"] forState:UIControlStateNormal];
    [backButton setImage:[UIImage imageNamed:@"back_nav_icon_press"] forState:UIControlStateHighlighted];
    backButton.imageEdgeInsets = UIEdgeInsetsMake(5, 12.8, 7, 18.8);
    [backButton addTarget:self action:@selector(clickBack) forControlEvents:UIControlEventTouchUpInside];
    [navigationBar addSubview:backButton];
    
    [backButton makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(navigationBar.top).offset(20);
        make.left.equalTo(navigationBar.left).offset(0);
        make.bottom.equalTo(navigationBar.bottom).offset(0);
        make.width.equalTo(44);
    }];
    
    
    mTableView = UITableView.new;
    mTableView.delegate = self;
    mTableView.dataSource = self;
    
    [self.view addSubview:mTableView];
    
    
    
    [mTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(parentView.left).offset(0);
        make.right.equalTo(parentView.right).offset(0);
        make.top.equalTo(navigationBar.bottom).offset(0);
        make.bottom.equalTo(parentView.bottom).offset(0);
    }];
    
}



- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier;
    
    CellIdentifier = @"AutoTableCell";
    
    
    AutoTableCell *cell = (AutoTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[AutoTableCell alloc] initWithStyle:UITableViewCellStyleDefault
                               reuseIdentifier:CellIdentifier];
    }
    
    
    
    return cell;
    
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

#pragma mark -----------------------------返回每个 cell 的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}






-(void)clickBack {
    
    [self.navigationController popViewControllerAnimated:YES];
}


/*
- (void)drawView {
    
    
    
    
    self.view.backgroundColor = UIColorFromRGB(0xEEEEEE);
    
    UIView *navigationBar = UIView.new;
    navigationBar.backgroundColor = MAIN_COLOR;
    [self.view addSubview:navigationBar];
    
    UIView *parentView = self.view;
    
    [navigationBar makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(parentView.top).offset(0);
        make.left.equalTo(parentView.left).offset(0);
        make.right.equalTo(parentView.right).offset(0);
        make.height.equalTo(54);
    }];
    
    UILabel *titleLabel = UILabel.new;
    titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
    titleLabel.text = @"关于我们";
    titleLabel.textColor = [UIColor whiteColor];
    [navigationBar addSubview:titleLabel];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(navigationBar);
        make.top.equalTo(navigationBar.top).offset(20);
        make.bottom.equalTo(navigationBar.bottom).offset(0);
    }];
    
    
    UIButton *rightButton = UIButton.new;
    rightButton.exclusiveTouch = YES;
    [rightButton addTarget:self action:@selector(menuToggle) forControlEvents:UIControlEventTouchUpInside];
    [navigationBar addSubview:rightButton];
    
    [rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(navigationBar.top).offset(20);
        make.right.equalTo(parentView.right).offset(0);
        make.size.equalTo(CGSizeMake(44, 34));
    }];
    
    UIImageView *imageView = UIImageView.new;
    imageView.image = [UIImage imageNamed:@"ic_menu_light"];
    [rightButton addSubview:imageView];
    
    [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(rightButton);
        make.size.equalTo(CGSizeMake(24, 24));
    }];
}


- (void) menuToggle {
    [self dismissViewControllerAnimated:YES completion:nil];
    //BaseNavigationController *nav = (BaseNavigationController *)self.navigationController;
    //[nav showMenu];
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
